home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / networking / applic / ntp / acts.zoo / makcfg.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-10-15  |  34.6 KB  |  963 lines

  1. main()
  2. {
  3. /*
  4.         This is program MAKCFG.  it is used to make
  5.         a configuration file for use by program nbstime.
  6.         it builds the file based on the answers to a series
  7.         of questions.
  8.     this program can be used to build different versions
  9.     of the configuration file depending on which system
  10.     nbstime will be used.  note that not all of the following
  11.     variables are used by all versions
  12. */
  13. #include <stdio.h>
  14. #include <ctype.h>
  15. char number[30];     /* holds telephone number */
  16. char path[40];        /* holds path name for sun system port*/
  17. char dv1,dv2;         /* sun system port alphanumeric chars */
  18. char cmport;          /* holds comport, 1,2 (or 3,4 for non-bios calls */
  19. char cmadr[4];         /* holds com port hardware address if necessary */
  20. int bios;            /* 1 for bios i/o, 0 for non-bios calls */
  21. char echo;            /* e for echo, b for blind*/
  22. char hs;             /* h for 1200, l for 300 */
  23. char lpt;            /* y pulse lpt port, n do not pulse */
  24. char setclk;         /* s, set clocks, d do not set them */
  25. char utcdif[4];          /* local time - utc in hours */
  26. int dsflag;          /* 1 for daylight savings time, 0 for no */
  27. int atflag;          /* 1 for AT with CMOS clock, 0 for no    */
  28. char wrtdif;         /* a to write time difference to NBSTIME.DIF, n=don't)*/
  29. char buf[30],cc,dd;     /* temporary register for answers  */
  30. char *help0,*help1,*help2,*help3,*help4,*help5,*help6,*help7,*help8;
  31. char *help9,*helpa,*helpb,*helpc,*helpd,*helpe,*helpf,*helpg;
  32. int stat;            /* 1 means reply ok, 0 means reply in error */
  33. int mach;     /* 1=IBMPC, 2=SUN, 3=RSX11M, 4=VAX/VMS */
  34. int j,k;
  35. FILE *fopen();
  36. FILE *iop;
  37. char *fname;
  38. /*
  39.     the sun version of C does not recognize the __DATE__
  40.     macro so define it here as a simple string.  the pre-processor
  41.     in Turbo C will assign the compilation date to this string
  42.     automatically
  43. */
  44. char *DATE;
  45. #ifdef SUN
  46.     DATE="29 sep 88";
  47. #endif
  48. /*
  49.         following are texts of help messages
  50. */
  51.         help0="\n This program uses your answers to generate a file\
  52.                \n named nbstime.cfg in your current default directory.\
  53.                \n If a file by this name already exists there,\
  54.                \n this question allows you to stop before the existing\
  55.                \n file is overwritten, which will happen if you select\
  56.                \n the Continue option.  If you select Rename, the\
  57.                \n existing file is renamed to config.old and then\
  58.                \n a new file named nbstime.cfg is produced.\
  59.                \n The rename will fail if config.old already exists.";
  60.         help1="\n This question is used to generate responses for the\
  61.                \n first line of the configuration file.  Tone dialing\
  62.                \n uses Touch Tone frequencies to dial, pulse dialing\
  63.                \n simulates a rotary dial telephone and manual dialing\
  64.                \n means that the user will make the connection outside\
  65.                \n of the program.";
  66.         help2="\n Enter n <return> here if you are directly connected\
  67.                \n to an outside line.  If you need to dial a digit to\
  68.                \n be connected to an outside line, enter it here.\
  69.                \n Typical responses are 9 or 8.";
  70.         help3="\n If you are in the Denver Metro calling area, then\
  71.                \n no long distance access is required so answer n.\
  72.                \n If you are outside of Denver Metro but in area 303\
  73.                \n then usually only the digit 1 is required.\
  74.                \n If you are outside of area 303 then some systems\
  75.                \n require 1 303, while others require only 303.\
  76.                \n If your system is none of the above, respond with\
  77.                \n o and you will be prompted for the required string.";
  78.         help4="\n If a billing number or other code is required AFTER\
  79.                \n the number is dialed, enter it here, terminated with\
  80.                \n <return>. Use a comma in the string if a 2-second\
  81.                \n pause if necessary.  If billing number is not required\
  82.                \n just enter <return>.  The string is not checked.";
  83.         help5="\n Enter the port that will be used to connect the\
  84.                \n computer to the external modem.  Only COM1 or COM2\
  85.                \n may be used if input/output via BIOS calls was\
  86.                \n selected above.  If direct i/o was selected, COM3 or\
  87.                \n COM4 may also be used.  If an internal modem is used,\
  88.                \n it must be configured as the selected COM port.  If\
  89.                \n direct i/o was selected you may specify the port using\
  90.                \n its hardware address, and you may have to do so if you\
  91.                \n plan to use COM3 or COM4 and if the hardware address\
  92.                \n of the port is not stored in the equipment table in\
  93.                \n memory.  Typical responses are 3f8, 2f8, 3e8 and 2e8\
  94.                \n for ports 1 - 4 respectively, but your response will\
  95.                \n depend on your hardware configuration.  The addresses\
  96.                \n can usually be found in your hardware manuals.";
  97.         help6="\n If the modem echoes commands followed by OK when it\
  98.                \n is in command mode, then respond E to this query.\
  99.                \n If the modem does not echo the commands then respond\
  100.                \n B (for blind dialing).  This capability is usually set\
  101.                \n by means of switches inside the modem.  If you enter\
  102.                \n E and the modem in fact does not respond as expected\
  103.                \n then the program will halt with a message that the\
  104.                \n modem did not respond.  If you enter B then the\
  105.                \n program will wait for a response, but will simply\
  106.                \n continue if no response is received within about\
  107.                \n 3 seconds.  If you are in doubt, you should use\
  108.                \n B, but this will bypass some of the error detection\
  109.                \n capabilities of the program.";
  110.         help7="\n The program converts from Universal Time as received\
  111.                \n from NBS to the local time zone of the user using\
  112.                \n this answer. The conversion is disabled for z, and\
  113.                \n the computer will be set to Universal (Greenwich)\
  114.                \n time.  For non-US time zones, the correction may be\
  115.                \n specified numerically by first responding n and then\
  116.                \n giving the difference (in hours) between local time\
  117.                \n and Universal (Greenwich) Time.  Locations West of\
  118.                \n Greenwich will have negative offsets, while those\
  119.                \n East of Greenwich will be positive.  You may also\
  120.                \n specify your time zone by letter.  To do so, respond\
  121.                \n with a * here.";
  122.         help8="\n The program will set the computer to Daylight\
  123.                \n Savings Time based on the Daylight Savings Time\
  124.                \n flag from the received message and your answer to\
  125.                \n this question.  If you answer y(es), the flag in the\
  126.                \n received message will be tested and the conversion\
  127.                \n will be applied if necessary.  If you answer n(o)\
  128.                \n the received flag will be ignored and only the time\
  129.                \n zone correction will be applied.";
  130.         help9="\n The program will always set or check the computer\
  131.                \n clock stored in memory and read by the 'time'\
  132.                \n and 'date' commands.  If you have an AT-type machine\
  133.                \n or equivalent, it may also have a second clock that\
  134.                \n runs from a battery even when the main power is off.\
  135.                \n If you answer y(es), the program will also set or check\
  136.                \n this clock.  If you answer n(o), the battery clock will\
  137.                \n not be set.  Since the time will only be set in the\
  138.                \n clock that is stored in the volatile computer memory\
  139.                \n in this case, the time will be lost when the power\
  140.                \n is turned off.";
  141.         helpa="\n You can select transmission at 300 bits/s using 103-type\
  142.                \n modems or 1200 bits/s using 212A modems.  The lower speed\
  143.                \n provides only the hour-minute-second and the telephone\
  144.                \n line time delay and is intended for users who will use\
  145.                \n the output pulse capability or the terminator only.\
  146.                \n If 300 bits/s is selected, the clock will not be set.\
  147.                \n The 1200 bits/s service provides the full time and date\
  148.                \n and is intended primarily for users who want to set the\
  149.                \n time and date, although output pulses can also be\
  150.                \n selected in this mode.";
  151.         helpb="\n If you answer yes to this question, a negative pulse\
  152.                \n will be sent to the line-printer port every second\
  153.                \n when the on-time character is received from NBS.\
  154.                \n The pulse will appear on pin 1 of the female DB25\
  155.                \n connector used for the line printer.  Pin 25 of the\
  156.                \n same connector is ground.  You must have a parallel\
  157.                \n printer adapter configured as LPT1. The program\
  158.                \n will attempt to ascertain its hardware address\
  159.                \n and will print a diagnostic if it fails to do so.\
  160.                \n You should disconnect the line printer if you intend\
  161.                \n to use this capability. If you answer No, the pulse\
  162.                \n generating logic is disabled.";
  163.         helpc="\n If you answer s (or S) to this question, and if you\
  164.                \n select 1200 bits/s communications, then the time of your\
  165.                \n computer clock will be set to the NBS time (converted\
  166.                \n to local time, if necessary).  If you answwer d (or D)\
  167.                \n the computer clocks will not be set.  The difference\
  168.                \n between NBS time and computer time is displayed in\
  169.                \n both cases.  Note that neither setting nor comparison\
  170.                \n are performed at 300 bits/s, since neither the date nor\
  171.                \n the Daylight Savings Time Flag are transmitted in that\
  172.                \n mode.";
  173.         helpd="\n If you answer yes to this question, the time\
  174.                \n differences between the computer clocks and NBS will be\
  175.                \n written to file NBSTIME.DIF.  If the file exists, the\
  176.                \n values will be appended to the end of the file.  If the\
  177.                \n file does not exist, it will be created.  Each line\
  178.                \n begins with the date and time of the comparison.  After\
  179.                \n that comes the offset of the clock stored in memory and\
  180.                \n finally offset of the IBMPC CMOS clock if it exists.  If a\
  181.                \n clock is fast with respect to NBS, its difference is\
  182.                \n positive; if slow it is negative.  The letters d, h, m,\
  183.                \n or s used after each value indicate days, hours,\
  184.                \n minutes or seconds, respectively.  If you answer r\
  185.            \n then in addition to storing the current time difference\
  186.            \n as just described, the program estimates the rate offset\
  187.            \n of the clock by subtracting the current time difference\
  188.            \n from the last difference read from the file NBSTIME.DIF\
  189.            \n and dividing by the elapsed time in days between the\
  190.            \n two comparisons.  The rate estimate is always given\
  191.            \n in units of sec/day. A positive value indicates that\
  192.            \n the computer clock is fast with respect to NBS.";
  193.         helpe="\n If you answer 1, NBSTIME will call the resident BIOS\
  194.                \n routines for input and output operations.  Only COM1\
  195.                \n and COM2 may be specified (a BIOS restriction), but\
  196.                \n the program is isolated from the detailed hardware\
  197.                \n configuration by the BIOS, and is therefore more\
  198.                \n likely to work with third-party hardware.  If you\
  199.                \n answer 0, input and output use direct commands to the\
  200.                \n hardware.  Any of the four COM ports may be used\
  201.                \n and the BIOS restriction that clear-to-send (CTS)\
  202.                \n must be true is removed.  The hardware registers\
  203.                \n must conform to the technical description in the\
  204.                \n IBM technical manuals, and the program may not work\
  205.                \n with third-party systems or with future versions of\
  206.                \n the personal-computer hardware.  The comport may be\
  207.                \n specified either by number as 1, 2, 3, or 4 or by\
  208.                \n its hardware address.";
  209.     helpf="\n The configuration files for the different versions\
  210.            \n of the program differ, and the answer to this question\
  211.            \n is used to select the questions you will be asked\
  212.            \n and the acceptable responses.";    
  213.     helpg="\n For the sun system, the communication port may be\
  214.            \n specified using either one or two alphanumeric\
  215.         \n characters that are appended to the string /dev/tty\
  216.         \n to produce the device name.  Legal responses are the\
  217.            \n digits 0 - 9 and the letters a -z or A - Z.  The case\
  218.            \n of an alphabetic response is significant and must match\
  219.            \n the requirements of the target system.  If only one\
  220.            \n character is needed, the second should be entered as -.\
  221.            \n You may also specify the port by its full path name if\
  222.            \n the form /dev/ttyxx is not suitable.  In that case,\
  223.            \n respond - to this question.  The program will then\
  224.         \n ask for the path name of the port to be used.  Your\
  225.         \n response is not parsed or validated and an error\
  226.         \n will only be detected when the program NBSTIME is run.";
  227.         printf("\nProgram to Generate Configuration File for NBSTIME.");
  228.         printf("\nVersion of %s",DATE);
  229.         printf("\nAll responses must end with <return>");
  230.         printf("\n Answer ? <return> at any time for more information");
  231. /*
  232.         first see if configuration file already exists
  233. */
  234.         fname="nbstime.cfg";
  235.         if( (iop=fopen(fname,"rt") ) != 0)
  236.         {
  237.         do
  238.         {
  239.         printf("\n\n\n A configuration file named %s already exists.",fname);
  240.         printf("\n If you want to");
  241.         printf("\n Continue and overwite the file, answer C <return>");
  242.         printf("\n Stop and think about it,        answer S <return>");
  243.         printf("\n Rename old file and continue,   answer R <return>");
  244.         printf("\n ans= ");
  245.         cc=getchar();
  246.         switch (cc)
  247.            {
  248.            case '?':
  249.               printf("%s",help0);
  250.               stat=0;
  251.               break;
  252.            case 's':
  253.            case 'S':
  254.               exit();
  255.               break;
  256.            case 'R':
  257.            case 'r':
  258.               if( fclose(iop) !=0 )
  259.                  {
  260.                  printf("\n close before rename failed.\n\n");
  261.                  exit();
  262.                  }
  263.               if( rename("nbstime.cfg","config.old") != 0)
  264.                  {
  265.                  printf("\n attempt to rename failed\n\n");
  266.                  exit();
  267.                  }
  268.               stat=1;
  269.               break;
  270.            case 'c':
  271.            case 'C':
  272.               if( fclose(iop) != 0)
  273.                  {
  274.                  printf("\n file close failed.\n\n");
  275.                  exit();
  276.                  }
  277.               stat=1;
  278.               break;
  279.            default:
  280.               printf("\n I don't understand %c",cc);
  281.               stat=0;
  282.            }
  283.         while( (cc=getchar() ) != '\n') ;
  284.         } while (stat == 0);
  285.         }  /* end of if file already existed open code */
  286. /*
  287.         now open it for real
  288. */
  289.         if( (iop=fopen(fname,"wt") )== 0)
  290.         {
  291.         printf("\n open for write failed.\n\n");
  292.         abort();
  293.         }
  294. /*
  295.     find out what the target machine will be
  296. */
  297.     do
  298.     {
  299.     printf("\n\n Which machine will you be using? \n Please enter:");
  300.     printf("\n i <return> for an IBMPC (or compatible) machine");
  301.     printf("\n s <return> for a SUN workstation.");
  302.     printf("\n v <return> for a VAX/VMS system.");
  303.     printf("\n r <return> for a PDP-11/RSX11M system.");
  304.     printf("\n ans=");
  305.     cc=getchar();
  306.     switch (cc)
  307.        {
  308.        case '?':
  309.         printf("%s",helpf);
  310.         stat=0;
  311.         break;
  312.        case 'i':
  313.        case 'I':
  314.         mach=1;
  315.         stat=1;
  316.         break;
  317.        case 's':
  318.        case 'S':
  319.         mach=2;
  320.         stat=1;
  321.         break;
  322.        case 'r':
  323.        case 'R':
  324.         mach=3;
  325.        case 'v':
  326.        case 'V':
  327.         mach=4;
  328.         printf("\n makcfg does not support these versions yet.");
  329.         stat = 0;
  330.         break;
  331.        default:
  332.         printf("\n I don't understand %c",cc);
  333.         stat=0;
  334.        }
  335.     while ( (cc=getchar() ) != '\n') ; /*skip newline*/
  336.     } while (stat == 0);
  337. /*
  338.         ask if bios calls will be used. if yes only com1 and com2
  339.         if no then com3 and com4 can also be used and the address
  340.         can be specified as a hardware port number
  341. */
  342.    if(mach == 1)    /* this question only for IBMPC version */
  343.     {
  344.         do
  345.         {
  346.         printf("\n  Please enter:");
  347.         printf("\n  1 <return> if input/output will use BIOS");
  348.         printf("\n  0 <return> if input/output via direct access");
  349.         printf("\n ans= ");
  350.         cc=getchar();
  351.         switch (cc)
  352.            {
  353.            case '1':
  354.               bios=1;
  355.               stat=1;
  356.               break;
  357.            case '0':
  358.               bios=0;
  359.               stat=1;
  360.               break;
  361.            case '?':
  362.               printf("%s",helpe);
  363.               stat=0;
  364.               break;
  365.            default:
  366.               printf("\n I don't understand %c",cc);
  367.               stat=0;
  368.               break;
  369.            }
  370.         while( (cc = getchar() ) != '\n' )   ; /*skip to newline*/
  371.         } while (stat == 0);
  372.     }
  373.         do
  374.         {
  375.         printf("\n1a.  Dialing Mode.  Please enter:");
  376.         printf("\n       T <return> for tone (push-button) dialing");
  377.         printf("\n       P <return> for pulse (rotary) dialing");
  378.         printf("\n       M <return> for manual dialing");
  379.         printf("\n   ans= ");
  380.         cc=getchar();
  381.         switch (cc)
  382.            {
  383.            case 't':
  384.            case 'T':
  385.               number[0]='T';
  386.               stat=1;
  387.               break;
  388.            case 'm':
  389.            case 'M':
  390.               strcpy(number,"Manual Dialing");
  391.               k=14;
  392.               stat=1;
  393.               break;
  394.            case 'p':
  395.            case 'P':
  396.               number[0]='P';
  397.               stat=1;
  398.               break;
  399.            case '?':
  400.               printf("%s",help1);
  401.               stat=0;
  402.               break;
  403.            default:
  404.               printf("\n I don't understand %c",cc);
  405.               stat=0;
  406.               break;
  407.            }
  408.         while( (cc=getchar() ) != '\n') ;   /* skip to newline character*/
  409.         } while (stat == 0);
  410. /*
  411.         skip all the rest if manual dialing selected
  412. */
  413.         if(number[0] != 'M')
  414.         {
  415.         do
  416.         {
  417.         printf("\n\n1b. Outside Line Access ?");
  418.         printf("\n  n <return> if not required");
  419.         printf("\n  otherwise enter digit <return>.");
  420.         printf("\n  ans = ");
  421.         cc=getchar();
  422.         switch (cc)
  423.            {
  424.            case '?':
  425.               printf("%s",help2);
  426.               stat=0;
  427.               break;
  428.            case 'n':
  429.            case 'N':
  430.               number[1]=' ';
  431.               k=2;
  432.               stat=1;
  433.               break;
  434.            case '0':
  435.            case '1':
  436.            case '2':
  437.            case '3':
  438.            case '4':
  439.            case '5':
  440.            case '6':
  441.            case '7':
  442.            case '8':
  443.            case '9':
  444.               number[1]=cc;
  445.               number[2]=',';
  446.               number[3]=' ';
  447.               k=4;
  448.               stat=1;
  449.               break;
  450.            default:
  451.               printf("\nI don't understand %c",cc);
  452.               stat=0;
  453.               break;
  454.            }
  455.            while( (cc=getchar() ) != '\n') ;  /*skip to newline character*/
  456.            } while (stat == 0);
  457.         do
  458.         {
  459.         printf("\n\n1c. Long Distance Access, Enter");
  460.         printf("\n   n <return> if not required");
  461.         printf("\n   1 <return> if only 1 is required");
  462.         printf("\n   2 <return> if only 303 area code required");
  463.         printf("\n   3 <return> if 1 and 303 both required");
  464.         printf("\n   o <return> if some other access required");
  465.         printf("\n  ans =  ");
  466.         cc=getchar();
  467.         switch (cc)
  468.            {
  469.            case '?':
  470.               printf("%s",help3);
  471.               stat=0;
  472.               break;
  473.            case 'n':
  474.            case 'N':
  475.               stat=1;
  476.               break;
  477.            case '1':
  478.               number[k]='1';
  479.               k++;
  480.               stat=1;
  481.               break;
  482.            case '3':
  483.               number[k]='1';
  484.               k++;
  485.            case '2':
  486.               number[k]='3';
  487.               k++;
  488.               number[k]='0';
  489.               k++;
  490.               number[k]='3';
  491.               k++;
  492.               stat=1;
  493.               break;
  494.            case 'o':
  495.            case 'O':
  496.               while( (cc=getchar() ) != '\n') ; /* skip <return> from o ans*/
  497.               printf("\n Enter Long Distance Access, end with <return>");
  498.               printf("\n ans=");
  499.               while( (cc=getchar() ) != '\n') number[k++]=cc;
  500.               ungetc('\n',stdin);     /* push this <return> back */
  501.               stat=1;
  502.               break;
  503.            default:
  504.               printf("\n I don't understand %c",cc);
  505.               stat=0;
  506.               break;
  507.            }
  508.         while( (cc=getchar() ) != '\n') ;  /* skip to end of line*/
  509.         } while (stat == 0);
  510.         strcpy(&number[k]," 494 4774");
  511.         k +=9;
  512.         do
  513.         {
  514.         printf("\n\n1d. If Accounting codes are necessary after the");
  515.         printf(" telephone number, Enter \n");
  516.         printf("\n      <return> if not needed");
  517.         printf("\n      or codes <return>");
  518.         printf("\n ans = ");
  519.         gets(buf);
  520.         if( buf[0] == '?')
  521.            {
  522.            printf("%s",help4);
  523.            stat=0;
  524.            }
  525.         else
  526.            {
  527.            if(buf[0] != '\0') number[k++]=',';  /*add 1 pause by default*/
  528.            for(j=0; buf[j] != 0; j++) number[k++]=buf[j];
  529.            stat=1;
  530.            }
  531.         } while (stat == 0);
  532.         }
  533.         number[k]='\0';
  534.         do
  535.         {
  536.         printf("\n\n2a. Which Serial Port will be used? \n    Enter:");
  537.    if(mach == 1)
  538.       {
  539.         printf("\n 1 <return> for COM1");
  540.         printf("\n 2 <return> for COM2");
  541.         if(bios == 0)
  542.            {
  543.            printf("\n 3 <return> for COM3");
  544.            printf("\n 4 <return> for COM4");
  545.            printf("\n h <return> to specify the port by its hardware address");
  546.            }
  547.       }
  548.    if(mach == 2)
  549.       {
  550.     printf("\n a- <return> to specify port /dev/tty<a>");
  551.     printf("\n ab <return> to specify port /dev/tty<a><b>");
  552.     printf("\n -  <return> to specify port by its path name.");
  553.       }
  554.         printf("\n ans =");
  555.         cc=getchar();
  556.    if(mach == 2)
  557.       {
  558.        switch (cc)
  559.     {
  560.     case '?':
  561.        printf("%s",helpg);
  562.        stat=0;
  563.        break;
  564.     case '-':
  565.        dv1=cc;
  566.        while( (cc=getchar() ) != '\n') ; /* skip pending newline*/
  567.        printf("\n path name of port=");
  568.        scanf("%s",path);
  569.        stat=1;
  570.        break;
  571.     default:
  572.        dv1=cc;
  573.        dv2=getchar();
  574.        if( isalnum(dv1) && ( (dv2 == '-') || isalnum(dv2) ) )
  575.         {
  576.         stat=1;
  577.         break;
  578.         }
  579.        else
  580.         {
  581.         printf("\n response must be letter or digit.");
  582.         stat=0;
  583.         break;
  584.         }
  585.       }
  586.       }
  587.    if(mach == 1)
  588.       {
  589.         switch (cc)
  590.            {
  591.            case '?':
  592.               printf("%s",help5);
  593.               stat=0;
  594.               break;
  595.            case '1':
  596.            case '2':
  597.               cmport=cc;
  598.               stat=1;
  599.               break;
  600.            case '3':
  601.            case '4':
  602.               cmport=cc;
  603.               stat=1 - bios;      /* only legal if bios == 0 */
  604.               if(stat == 0) printf("\n COM%c not supported by BIOS",cc);
  605.               break;
  606.            case 'h':
  607.            case 'H':
  608.               cmport='h';
  609.               stat=1 - bios;      /* only legal if bios == 0 */
  610.               if(stat == 1)
  611.               {
  612.                  while( (cc=getchar() ) != '\n'); /* skip pending newline*/
  613.                  printf("\n Hardware address of port=");
  614.                  for(j=0; j<3; j++)
  615.                  {
  616.                     cc=getchar();
  617.                     if(isxdigit(cc) != 0) cmadr[j]=cc;
  618.                     else
  619.                     {
  620.                        printf("\n address must have only hex digits.");
  621.                        stat=0;
  622.                        break;
  623.                     }
  624.                  }
  625.               cmadr[3]='\0';
  626.               }
  627.               else
  628.                  printf("\n cannot use hardware address in BIOS mode");
  629.               break;
  630.            default:
  631.               printf("\n I don't understand %c",cc);
  632.               stat=0;
  633.               break;
  634.            }
  635.       }
  636.         while( (cc=getchar() ) != '\n') ; /*skip rest of line */
  637.         } while (stat == 0);
  638.         do
  639.         {
  640.         printf("\n2b. Specify Modem Responses to Commands, Enter");
  641.         printf("\n E if modem echoes commands\n B if it does not");
  642.         printf("\n ans =");
  643.         cc=getchar();
  644.         switch (cc)
  645.            {
  646.            case '?':
  647.               printf("%s",help6);
  648.               stat=0;
  649.               break;
  650.            case 'e':
  651.            case 'E':
  652.               echo='e';
  653.               stat=1;
  654.               break;
  655.            case 'b':
  656.            case 'B':
  657.               echo='b';
  658.               stat=1;
  659.               break;
  660.            default:
  661.               printf("\n I don't understand %c",cc);
  662.               stat=0;
  663.               break;
  664.            }
  665.         while( (cc=getchar() ) != '\n') ;
  666.         } while (stat == 0);
  667.         do
  668.         {
  669.         printf("\n\n2c. Specify Transmission Speed and protocol");
  670.         printf("\n\n    Enter");
  671.         printf("\n\n    h <return> for 1200 bits/s, 212A Modem");
  672.         printf("  \n    l <return> for  300 bits/s, 103  Modem");
  673.         printf("  \n ans= ");
  674.         cc=getchar();
  675.         switch (cc)
  676.            {
  677.            case '?':
  678.               printf("%s",helpa);
  679.               stat=0;
  680.               break;
  681.            case 'h':
  682.            case 'H':
  683.            case 'l':
  684.            case 'L':
  685.               hs=cc;
  686.               stat=1;
  687.               break;
  688.            default:
  689.               printf("\n I don't understand %c",cc);
  690.               stat=0;
  691.            }
  692.         while( (cc=getchar() ) != '\n'); /* skip to newline */
  693.         } while (stat == 0);
  694.    if(mach == 1)    /* only IBMPC version can pulse line printer port*/
  695.      {
  696.         do
  697.         {
  698.         printf("\n\n2d. Pulse Line-Printer Port Each Second?");
  699.         printf("\n\n    Enter");
  700.         printf("\n\n    y <return> for yes");
  701.         printf("  \n    n <return> for no");
  702.         printf("\n\n    ans= ");
  703.         cc=getchar();
  704.         switch (cc)
  705.            {
  706.            case '?':
  707.              printf("%s",helpb);
  708.              stat=0;
  709.              break;
  710.            case 'y':
  711.            case 'Y':
  712.            case 'n':
  713.            case 'N':
  714.               lpt=cc;
  715.               stat=1;
  716.               break;
  717.            default:
  718.               printf("\n I don't understand %c",cc);
  719.               stat=0;
  720.               break;
  721.            }
  722.         while( (cc=getchar() ) != '\n') ;
  723.         } while (stat == 0);
  724.      }
  725.         do
  726.         {
  727.         printf("\n\n2e. Set computer clocks to received time?");
  728.         printf("  \n     Enter");
  729.         printf("  \n     s <return> for set enable");
  730.         printf("  \n     d <return> for set disable");
  731.         printf("  \n     ans= ");
  732.         cc=getchar();
  733.         switch (cc)
  734.            {
  735.            case '?':
  736.               printf("%s",helpc);
  737.               stat=0;
  738.               break;
  739.            case 's':
  740.            case 'S':
  741.            case 'd':
  742.            case 'D':
  743.               setclk=cc;
  744.               stat=1;
  745.               break;
  746.            default:
  747.               printf("\nI don't understand %c",cc);
  748.               stat=0;
  749.               break;
  750.            }
  751.         while( (cc=getchar()) != '\n')  ;
  752.         }  while (stat == 0);
  753.         do
  754.         {
  755.         printf("\n\n2f. Write Time Differences to file NBSTIME.DIF ?");
  756.         printf("  \n    Enter");
  757.         printf("  \n    y <return> for yes");
  758.         printf("  \n    n <return> for no");
  759.     printf("  \n    r <return> for yes and estimate rate too");
  760.         printf("\n\n    ans= ");
  761.         cc=getchar();
  762.         switch (cc)
  763.            {
  764.            case '?':
  765.               printf("%s",helpd);
  766.               stat=0;
  767.               break;
  768.            case 'y':
  769.            case 'Y':
  770.               wrtdif='a';
  771.               stat=1;
  772.               break;
  773.            case 'n':
  774.            case 'N':
  775.               wrtdif='n';
  776.               stat=1;
  777.               break;
  778.        case 'r':
  779.        case 'R':
  780.           wrtdif='A';
  781.           stat=1;
  782.           break;
  783.            default:
  784.               printf("\nI don't understand %c",cc);
  785.               stat=0;
  786.               break;
  787.            }
  788.         while( (cc=getchar() ) != '\n') ;
  789.         } while (stat == 0);
  790.    if(mach == 1)
  791.      {
  792.         do
  793.         {
  794.         printf("\n3. Specify time zone for conversion to local time:");
  795.         printf("\n e <return> for U. S. Eastern Time");
  796.         printf("\n c <return> for U. S. Central Time");
  797.         printf("\n m <return> for U. S. Mountain Time");
  798.         printf("\n p <return> for U. S. Pacific Time");
  799.         printf("\n z <return> for Universal (Greenwich) Time");
  800.         printf("\n n <return> to enter time offset numerically");
  801.         printf("\n * <return> to enter time zone alphabetically");
  802.         printf("\n ans= ");
  803.         cc=getchar();
  804.         switch (cc)
  805.            {
  806.            case '?':
  807.               printf("%s",help7);
  808.               stat=0;
  809.               break;
  810.            case 'e':
  811.            case 'E':
  812.            case 'c':
  813.            case 'C':
  814.            case 'm':
  815.            case 'M':
  816.            case 'p':
  817.            case 'P':
  818.            case 'z':
  819.            case 'Z':
  820.               utcdif[0]=cc;
  821.               utcdif[1]='\0';
  822.               stat=1;
  823.               break;
  824.            case '*':
  825.               while( (cc=getchar() ) != '\n');  /* discard pending newline*/
  826.               printf("\n Time Zone letter (Any except j) =");
  827. /*
  828.         read character, convert to upper case
  829.         then signal error if J or non-letter
  830. */
  831.               cc=toupper( getchar() );
  832.               if( (cc == 'J') || (isalpha(cc) == 0) )
  833.                 {
  834.                 printf("\n Response must be any letter except j.");
  835.                 stat=0;
  836.                 break;
  837.                 }
  838. /*
  839.         remove ASCII offset of letters
  840.         we now have A=1, B=2, etc.
  841. */
  842.               k= (int) cc - 64;
  843. /*
  844.         since j is not used, k, l, m have one
  845.         value too high
  846. */
  847.               if( (k == 11) || (k == 12) || (k == 13) ) k--;
  848. /*
  849.         if letter was n or later, then value is negative
  850. */
  851.               if(k >= 14) k= 13 - k;
  852. /*
  853.         special case for z, which is 0
  854. */
  855.               if(k == -13) k=0;
  856.               sprintf(&utcdif[0],"%+02.2i",k);
  857.               stat=1;
  858.               break;
  859.            case 'n':
  860.            case 'N':
  861.               while( (cc=getchar() ) != '\n') ; /* discard pending newline*/
  862.               printf("\n local time - Universal time in hours=");
  863.               j=0;
  864.               do
  865.                  {
  866.                  cc=getchar();
  867.                  if( (cc != '\n') && (j< 3) )utcdif[j++]=cc;
  868.                  else  utcdif[j]='\0';
  869.                  } while(cc != '\n');
  870.               stat=1;
  871.               ungetc('\n',stdin);
  872.               for(j=0; (cc=utcdif[j]) != 0 ; j++)
  873.               if( (isdigit(cc) == 0) && (cc != '+') && (cc != '-') )
  874.                  {
  875.                  printf("\n response must be a numerical value");
  876.                  stat=0;
  877.                  break;
  878.                  }
  879.               break;
  880.            default:
  881.               printf("\n I don't understand %c",cc);
  882.               stat=0;
  883.               break;
  884.            }
  885.         while( (cc=getchar() ) != '\n') ;  /* skip to new line char */
  886.         } while (stat == 0);
  887.         do
  888.         {
  889.         printf("\n\n4. Test for Daylight Savings Time? \n    Enter");
  890.         printf("  \n   y <return> for yes");
  891.         printf("  \n   n <return> for no ");
  892.         printf("\n   ans = ");
  893.         cc=getchar();
  894.         switch (cc)
  895.            {
  896.            case '?':
  897.               printf("%s",help8);
  898.               stat=0;
  899.               break;
  900.            case 'y':
  901.            case 'Y':
  902.               dsflag=1;
  903.               stat=1;
  904.               break;
  905.            case 'n':
  906.            case 'N':
  907.               dsflag=0;
  908.               stat=1;
  909.               break;
  910.            default:
  911.               printf("\n I don't understand %c",cc);
  912.               stat=0;
  913.               break;
  914.            }
  915.         while( (cc=getchar() ) != '\n');
  916.         } while (stat == 0);
  917.         do
  918.         {
  919.         printf("\n\n5.  Do you have a CMOS battery clock ?\n   Enter\n");
  920.         printf("  \n    y <return> for yes");
  921.         printf("  \n    n <return> for no");
  922.         printf("  \n   ans= ");
  923.         cc=getchar();
  924.         switch (cc)
  925.            {
  926.            case '?':
  927.               printf("%s",help9);
  928.               stat=0;
  929.               break;
  930.            case 'y':
  931.            case 'Y':
  932.               atflag=1;
  933.               stat=1;
  934.               break;
  935.           case 'n':
  936.           case 'N':
  937.               atflag=0;
  938.               stat=1;
  939.               break;
  940.           default:
  941.               printf("\n I don't understand %c",cc);
  942.               stat=0;
  943.               break;
  944.            }
  945.         while( (cc=getchar() ) !='\n');  /*skip to newline*/
  946.         } while (stat == 0);
  947.     }
  948.     fprintf(iop,"%s\n",number);
  949.     if(mach == 1)fprintf(iop,"%c",cmport);
  950.     if(mach == 2)
  951.        {
  952.        fprintf(iop,"%c",dv1);
  953.        if(isalnum(dv1)) fprintf(iop,"%c",dv2);
  954.        }
  955.         fprintf(iop,"%c%c",echo,hs);
  956.     if(mach == 1) fprintf(iop,"%c",lpt);
  957.     fprintf(iop,"%c%c\n",setclk,wrtdif);
  958.         if(mach == 1)fprintf(iop,"%s\n%1d\n%1d\n",utcdif,dsflag,atflag);
  959.         if( (mach == 1) && (cmport == 'h') ) fprintf(iop,"%s\n",cmadr);
  960.     if( (mach == 2) && (dv1 == '-') )fprintf(iop,"%s\n",path);
  961.         fclose(iop);
  962. }
  963.